<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
</html>

<script>
    class MyClass {
        #privateVariable;

        constructor(value) {
            this.#privateVariable = value;
        }

        getPrivateVariable() {
            return this.#privateVariable;
        }

        setPrivateVariable(value) {
            this.#privateVariable = value;
        }
    }

    const myClass = new MyClass('Hello, World!');


    console.log(myClass.#privateVariable)


    // console.log(myClass.getPrivateVariable()); // 输出：Hello, World!
    // myClass.setPrivateVariable('Private variable has been changed.');
    // console.log(myClass.getPrivateVariable()); // 输出：Private variable has been changed.

</script>
